package com.framework.component.extension;

import com.alibaba.fastjson.JSONObject;
import com.framework.component.extension.ability.SupplyDeptInfoAbility;
import com.framework.component.extension.context.BusinessDomainModel;
import com.framework.component.extension.context.ExtensionContext;
import com.framework.component.extension.context.vo.Student;
import com.framework.component.extension.register.ExtensionRepository;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ExtensionMain {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");

        ExtensionContext extensionContext = ExtensionContext.builder()
                .model(BusinessDomainModel.builder().student(Student.builder().build()).build())
                .build();

        // SupplyStudentInfoAbility supplyStudentInfoAbility = context.getBean("supplyStudentInfoAbility", SupplyStudentInfoAbility.class);
        // supplyStudentInfoAbility.execute(extensionContext);

        SupplyDeptInfoAbility supplyDeptInfoAbility = context.getBean("supplyDeptInfoAbility", SupplyDeptInfoAbility.class);
        supplyDeptInfoAbility.execute(extensionContext);

        System.out.println(JSONObject.toJSONString(extensionContext));

        ExtensionRepository extensionRepository = context.getBean("extensionRepository", ExtensionRepository.class);
        System.out.println(JSONObject.toJSONString(extensionRepository.getRepositoryRepo()));
    }
}
